feat: update insightsProject slug (CM-1043)#3923
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
This PR ensures that when a leaf segment (sub-project) slug is updated, the corresponding insightsProjects.slug stays in sync, relying on existing FK ON UPDATE CASCADE behavior for related securityInsights* tables. It also aims to address a DAL bug when creating collections with omitted optional fields.
Changes:
- Sync
insightsProjects.slugwhen a sub-project segment’s slug changes (normalizing by strippingnonlf_). - Rely on existing
ON UPDATE CASCADEto propagateinsightsProjectSlugchanges tosecurityInsights*tables. - Fix
createCollectionto default optional fields (logoUrl,imageUrl,color) tonullwhen omitted.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| backend/src/services/segmentService.ts | Updates linked insights project slug when a sub-project segment slug changes. |
| services/libs/data-access-layer/src/collections/index.ts | Adjusts collection creation to avoid errors when optional fields are omitted. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
b62af5f to
2dc232a
Compare
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org> Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>

Summary
insightsProjects.slugis now automatically synced.securityInsights*tables (securityInsightsEvaluationAssessments,securityInsightsEvaluationSuites,securityInsightsEvaluations) get theirinsightsProjectSlugupdated automatically via theON UPDATE CASCADEforeign keyconstraint already in place (migration
V1753457861).Changes
backend/src/services/segmentService.tsIn the
update()method, when a leaf segment's slug changes, the linkedinsightsProjectis looked up bysegmentIdand itsslug is updated (stripping the
nonlf_prefix, consistent with the creation flow).services/libs/data-access-layer/src/collections/index.tsFixed a bug in
createCollectionwhere optional fields (logoUrl,imageUrl,color) were not defaulted tonull, causing apg-promise error when callers omitted them.
Note
Medium Risk
Touches slug update flows across segments and insights projects and adds direct SQL updates to
securityInsights*tables; mistakes could cause stale analytics or unintended slug propagation. Scope is limited to update paths and guarded by conditions.Overview
Automatically syncs
insightsProjects.slugwhen a leaf segment (subproject) slug is updated, normalizing away thenonlf_prefix before updating the linked insights project.Makes insights project updates safer by only syncing
repositoryGroupswhen the field is explicitly provided, and when a project slug changes, explicitly bumpsupdatedAtonsecurityInsightsEvaluationSuites,securityInsightsEvaluations, andsecurityInsightsEvaluationAssessmentsso downstream ingestion (Tinybird) detects the cascaded slug update.Written by Cursor Bugbot for commit 2dc232a. This will update automatically on new commits. Configure here.